/**  
* @Title: LocationUtils.java
* @Package com.lemon.utils
* @Description: (一句话阐述):
* @author Ran_cc
* @date 2018年11月6日
* @version V1.0  
*/
package com.lemon.utils;

/**
 * <p>Title: LocationUtils</p>
 * <p>Description: 
 * </p>
 * <p>Company: </p>
 * @author Ran_cc
 * @date 2018年11月6日
 * @版本 V 1.0 
 */
public class LocationUtils {

	/// <summary>
	/// 获取2个地址的距离
	/// </summary>
	/// <param name="startLonLat">起始地经度纬度</param>
	/// <param name="endLonLat">目的地经度纬度</param>
	/// <returns></returns>
	public static int getDistance(String startLonLat , String endLonLat) {

		int duration = 0;  //起始地与目的地之间的距离
		String queryUrl = "http://restapi.amap.com/v3/distance?key=1b76797c593dff1bd16b6c80dc986b6d&origins="
				+ startLonLat + "&destination=" + endLonLat; //高德接口
		String queryResult = HttpUtil.doGet(queryUrl , null); //请求接口数据
		System.out.println(queryResult);
		//        int status = Utils.ObjToInt(jd["status"], 0);//查询结果 1:成功 0:失败 
		/*
		 * if (status == 1) //成功
		 * {
		 * JsonData list = jd["results"];
		 * if (list.Count > 0)
		 * {
		 * duration = Convert.ToInt32(Convert.ToInt64(list[0]["distance"].ToString()) / 1000);
		 * }
		 * }
		 */
		return duration;
	}
	public static void main(String[] args) {
		getDistance("119.956856,30.265898" , "119.958444,30.266561");
	}
}
